package com.lxq.blog.com.lxq.blog.dao;

import com.lxq.blog.com.lxq.blog.entity.User;
import com.lxq.blog.com.lxq.blog.util.RoleHandler;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface UserDao {
    @Select("select * from user")
    ArrayList<User> findAll();

    @Select("select * from user where user_name=#{userName}")
    @Results({@Result(property = "role",column = "role",typeHandler= RoleHandler.class),
    @Result(property = "userName",column = "user_name"),
    @Result(property = "nickName",column = "nick_name"),
    @Result(property = "registerDate",column = "register_date")})
    User findByUserName(String userName);
}
